<template>
	<view class="cardCoupons">
		<view class="listItem" v-for="(item,index) in props.list" :key="index">
			<view class="left">
				<image
				v-if="item.state.value != 'WAIT_USE'"
					:src="item.state.value == 'INVALID'?'/static/img/freeShipping/10.png':item.state.value == 'PENDING'?'/static/img/freeShipping/8.png':item.state.value == 'USED'?'/static/img/freeShipping/9.png':'/static/img/freeShipping/8.png'"
					mode="widthFix"></image>
				<text>免单购券</text>
				<view class="left_1">
					<text class="amount">{{item.couponAmount}}</text>
					{{item.couponName}}
				</view>
				<view class="right_1">
					<text>累计免单金额</text>
					{{item.createTime}}-{{item.invalidTime}}
				</view>
			</view>
			<view class="right">
				<text>无门槛</text>
				<text>全平台通用</text>
				<text @tap="navTo" v-if="item.state.value == 'WAIT_USE'">立即使用</text>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	const props = defineProps(['list'])
	const navTo = ()=>{
		uni.navigateTo({
			url:'/pages/life/index'
		})
	}
</script>

<style lang="scss" scoped>
	.cardCoupons {
		>view:nth-of-type(1) {
			margin-top: 0;
		}
	}

	.listItem {
		display: flex;
		margin-top: 24rpx;
		height: 200rpx;
		border-radius: 24rpx;
		overflow: hidden;
		background: #fff;

		>.left {
			flex: 1;
			position: relative;
			display: flex;
			flex-direction: column;
			justify-content: center;

			padding: 0 20rpx;
			>image{
				width: 180rpx;
				position: absolute;
				right: -35rpx;
				top: -45rpx;
			}
			>view{
				position: relative;
				z-index: 8;
			}
			>text {
				padding: 2rpx 12rpx;
				border-radius: 20rpx 0 20rpx 0;
				background: #FFD7AF;
				color: #C97210;
				z-index: 8;
				font-size: 24rpx;
				position: absolute;
				left: 0;
				top: 0;
			}

			.left_1 {
				display: flex;
				align-items: center;

				.amount {
					color: #FF263F;
					font-size: 64rpx;
					width: 180rpx;

					&:before {
						content: '￥';
						font-size: 36rpx;
						font-weight: bold;
						color: #FF263F;
					}
				}
			}

			.right_1 {
				display: flex;
				align-items: center;
				color: #8C8C8C;
				font-size: 20rpx;

				text {
					color: #8C8C8C;
					font-size: 20rpx;
					width: 180rpx;
				}
			}
		}

		>.right {
			background: linear-gradient(251deg, #FF3E61 0%, #FA2D1C 100%);
			box-shadow: -8rpx 0rpx 32rpx 0rpx rgba(255, 57, 43, 0.2);
			width: 246rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			position: relative;
			z-index: 8;
			text:nth-of-type(1) {
				font-size: 36rpx;
				color: #fff;
			}

			text:nth-of-type(2) {
				color: rgba(255, 255, 255, .8);
				font-size: 22rpx;
				margin: 10rpx 0;
			}

			text:nth-of-type(3) {
				padding: 2rpx 16rpx;
				border-radius: 16rpx;
				background: #fff;
				color: #FA2D1C;
				font-size: 24rpx;
			}
		}
	}
</style>